package com.jixiang.user.controller;



import com.baomidou.mybatisplus.extension.api.ApiController;
import com.jixiang.model.common.dtos.ResponseResult;
import com.jixiang.model.user.dtos.AdminUserDtos;
import com.jixiang.model.user.dtos.AppWxUserDtos;
import com.jixiang.model.user.dtos.WxIconDtos;
import com.jixiang.model.user.entity.UsUser;
import com.jixiang.user.service.UsUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (UsUser)表控制层
 *
 * @author makejava
 * @since 2023-10-12 13:57:50
 */
@RestController
@RequestMapping("user")
public class UserController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private UsUserService usUserService;


    /**
     * 登录功能
     *
     */
    @ApiOperation("获取管理者数据列表")
    @GetMapping("/getUserList")
    public ResponseResult getUserList(@RequestParam(value = "pageSize",required = false,defaultValue = "10")int pageSize,
                                       @RequestParam(value = "pageNum",required = false,defaultValue = "1")int pageNum,
                                       @RequestParam(value = "name",required = false,defaultValue = "")String name,
                                       @RequestParam(value = "phone",required = false,defaultValue = "")String phone){
        return usUserService.getUserList(pageNum,pageSize,name,phone);
    }

    /**
     * 修改用户状态
     *
     */
    @ApiOperation("修改用户状态")
    @PostMapping("/updateUserLevel")
    public ResponseResult updateUserLevel(@RequestParam(value = "id",required = true) String id){
            return usUserService.updateUserLevel(id);
    }

    /**
     * 修改用户等级
     *
     */
    @ApiOperation("修改用户等级")
    @PostMapping("/updateUserState")
    public ResponseResult updateUserState(@RequestParam(value = "id",required = true) String id){
        return usUserService.updateUserState(id);
    }

    /**
     * 修改用户状态
     *
     */
    @ApiOperation("修改用户状态")
    @GetMapping("/getUserById")
    public ResponseResult getAdminById(@RequestParam(value = "id",required = true) String id){
        return usUserService.getAdminById(id);
    }


    /**
     * 修改用户
     *
     */
    @ApiOperation("修改用户")
    @PostMapping ("/updateUser")
    public ResponseResult updateAdmin(@RequestBody(required = true) UsUser usUser){
        return usUserService.updateAdmin(usUser);
    }

    /**
     * 删除用户
     *
     */
    @ApiOperation("删除用户")
    @DeleteMapping ("/deleteUserById")
    public ResponseResult deleteAdminById(@RequestParam(value = "id",required = true) String id){
        return usUserService.deleteAdminById(id);
    }

    /**
     * 添加用户
     *
     */
    @ApiOperation("添加用户")
    @PostMapping ("/addUser")
    public ResponseResult addUser(@RequestBody(required = true) UsUser usUser){
        return usUserService.addUser(usUser);
    }


    @ApiOperation("用户端发送验证码")
    @GetMapping ("/appSendCode")
    public ResponseResult appSendCode(@RequestParam(required = true,value = "phone")String phone){
        return usUserService.appSendCode(phone);
    }

    @ApiOperation("用户端密码登入")
    @GetMapping ("/appLoginByUsername")
    public ResponseResult appLoginByUsername(@RequestParam(required = true,value = "name")String name,@RequestParam(required = true,value = "password")String password){
        return usUserService.appLoginByUsername(name,password);
    }

    @ApiOperation("用户端手机号登入")
    @GetMapping ("/appLoginByPhone")
    public ResponseResult appLoginByPhone(@RequestParam(required = true,value = "phone")String phone,@RequestParam(required = true,value = "password")String password){
        return usUserService.appLoginByPhone(phone,password);
    }

    @ApiOperation("微信模拟用户端手机号登入")
    @GetMapping ("/wxAppLoginByPhone")
    public ResponseResult wxAppLoginByPhone(@RequestParam(required = true,value = "phone")String phone){
        return usUserService.wxAppLoginByPhone(phone);
    }

    @ApiOperation("wx用户图片上传")
    @PostMapping ("/updateWxUserIconImage")
    public Boolean updateWxUserIconImage(@RequestBody(required = true) WxIconDtos wxIconDtos){
        return usUserService.updateWxUserIconImage(wxIconDtos);
    }

    @ApiOperation("微信获取用户信息")
    @GetMapping ("/wxAppGetwxUserData")
    public ResponseResult wxAppGetwxUserData(){
        return usUserService.wxAppGetwxUserData();
    }

    @ApiOperation("微信修改用户信息")
    @PostMapping ("/wxAppUpdateWxUser")
    public ResponseResult wxAppUpdateWxUser(@RequestBody(required = false) AppWxUserDtos appWxUserDtos){
        return usUserService.wxAppUpdateWxUser(appWxUserDtos);
    }


}

